package com.mq.core.container;

import com.mq.core.Message;
import lombok.Data;
import org.springframework.data.redis.core.RedisTemplate;

import java.lang.reflect.Method;

/**
 * 容器抽象类
 */
@Data
public abstract class AbstractMessageListenerContainer {

    private String[] queueName;
    private Object bean;
    private Method method;
    private String id;

    private RedisTemplate<String, String> redisTemplate;

    private volatile boolean quit;

    /**
     * 相关的一些配置
     */
    private int maxConsumer;
    private int retryTimes;

    protected void invoke(Message message) throws Exception {
        try {
            method.invoke(bean, message);
        }catch (Exception e){
            throw e;
        }
    }

    public abstract void doStart();

    public void start(){
        doStart();
    }
}
